function [] = edge_detection_sobel(input,output, threshold)

M_ORG = imread(input);

[h,w,d] = size(M_ORG);
if (d  == 3)
	M_ORG = M_ORG(:,:,1)*0.3 + M_ORG(:,:,2)*0.6 + M_ORG(:,:,3)*0.1;
end

[MAG,PHASE] = sobel(M_ORG);
[height,width] = size(MAG);

for i=1:height
        for j=1:width
                if (MAG(i,j) > threshold)
                        M_SOBEL_FINAL(i,j) = 0;
                else
                        M_SOBEL_FINAL(i,j) = 255;
                end
        end
end

imwrite(M_SOBEL_FINAL,output);
